import messageUtil from "../utils/messageUtil"
import data from "./data"
import httpUtil from "../utils/httpUtil"
import logApi from "./logApi"
import commonApi from "./commonApi"


function submitOrder(params, successCallBack, errCallBack) {
   

  logApi.addKeepLog('版本号' + commonApi.currentVersion + '，下单前请求参数：' + JSON.stringify(params))
  messageUtil.showLoading()
  httpUtil.post("/api/clhk/subOrder", params, res => {
    logApi.addKeepLog('版本号' + commonApi.currentVersion + '，下单后返回，参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(res))
    messageUtil.closeLoading()
    if (successCallBack) {
      successCallBack(res)
    }
  }, err => {
    logApi.addKeepLog('版本号' + commonApi.currentVersion + ',下单发生错误，参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(err))
    messageUtil.closeLoading()
    if (errCallBack) {
      errCallBack(err)
    }
  })
}


function submitOrders(params, successCallBack, errCallBack) {
   

  logApi.addKeepLog('版本号' + commonApi.currentVersion + '，下单前请求参数：' + JSON.stringify(params))
  messageUtil.showLoading()
  httpUtil.post("/api/rf/subOrder", params, res => {
    logApi.addKeepLog('版本号' + commonApi.currentVersion + '，下单后返回，参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(res))
    messageUtil.closeLoading()
    if (successCallBack) {
      successCallBack(res)
    }
  }, err => {
    logApi.addKeepLog('版本号' + commonApi.currentVersion + ',下单发生错误，参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(err))
    messageUtil.closeLoading()
    if (errCallBack) {
      errCallBack(err)
    }
  })
}

module.exports = {
  submitOrder: submitOrder,
  submitOrders:submitOrders
}